<?php

namespace app\models;
use yii\db\ActiveRecord;
use yii;
use yii\helpers\ArrayHelper;
use app\common\Functions;

class Contract extends ActiveRecord
{


    public function getTheSubjects()
    {
        return $this->hasOne(TheSubject::className(), ['contract_id' => 'id'] );

    }
    public function getAttrSpecs()//特性表
    {
        return $this->hasOne(AttrSpec::className(), ['attr_spec_id' => 'attr_spec_id'] )->viaTable(TheSubject::tableName() . 'as a1',  ['contract_id' => 'id']);
    }
    public function getCusts()
    {
        return $this->hasOne(Cust::className(), ['id' => 'context'])->viaTable(TheSubject::tableName() . 'as b1',  ['contract_id' => 'id']);

    }

    public function getProdInsts()
    {
        return $this->hasOne(ProdInst::className(), ['id' => 'context'])->viaTable(TheSubject::tableName() . 'as c1',  ['contract_id' => 'id']);
    }

}

?>
